﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebInvoicingsys.basecontrol.business
{
    public partial class uc_search_dates : System.Web.UI.UserControl
    {
        public string getValue()
        {
            return requestedDeliveryDateTextBox.Text.Trim();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                requestedDeliveryDateTextBox.Text = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }

        /// <summary>
        /// 日期选择图标被点击
        /// </summary>
        protected void ImageButton_Click(object sender, EventArgs eventArgs)
        {
            //控制日历的显示与隐藏
            calendar.Visible = !calendar.Visible;
        }

        /// <summary>
        /// 选择日期，通过AJAX触发
        /// </summary>
        protected void RequestedDeliveryDateCalendar_SelectionChanged(object sender, EventArgs eventArgs)
        {
            DateTime select_dates = requestedDeliveryDateCalendar.SelectedDate;

            requestedDeliveryDateTextBox.Text = select_dates.ToString("yyyy-MM-dd");

            // 隐藏日历
            calendar.Visible = false;

            //设置日历下textbox的焦点，方便用户输入。移除或改变下行代码设置为您自己的控件
            requestedDeliveryDateTextBox.Focus();
        }
    }
}